import React from 'react'

import { connect } from 'react-redux'

import {
  odooActionCreators,
} from '../redux'
import FavoritePosts from '../components/FavoritePosts'

const mapStateToProps = (state) => ({
  favorites: state.odoo.userInfo.favorites.video,
  likes: state.odoo.userInfo.likes.video,
  tag: 'video'
})

const mapDispatchToProps = (dispatch) => ({
  onFavoritePress: (data, isFavorited) => {
    const tag = 'video'
    const level = 'favorite'
    if (isFavorited) {
      dispatch(odooActionCreators.delFavoritePost(data.id, tag, level))
    } else {
      dispatch(odooActionCreators.favoritePost(data, tag, level))
    }
  },
  onLikePress: (data, isLiked) => {
    const tag = 'video'
    const level = 'like'
    if (isLiked) {
      dispatch(odooActionCreators.delFavoritePost(data.id, tag, level))
    } else {
      dispatch(odooActionCreators.favoritePost(data, tag, level))
    }
  }
})

export default connect(mapStateToProps, mapDispatchToProps)(FavoritePosts)
